#include<iostream>
using namespace std;
class Date {
private:
	int year;
	int month;
	int day;
public:
	Date(int y = 2004, int m = 1, int d = 1) :year(y), month(m), day(d) {

	}
	bool isLeapYear() {
		return year % 400 == 0 || year % 4 == 0 && year % 100 != 0;
	}
	int getDay() {
		int num = 0;
		int p[12] = { 31,28,31,30,31,30,31,31,30,31,30,31 };
		if (isLeapYear()) {
			p[1]++;
		}
		for (int i = 1; i < month; i++) {
			num += p[i - 1];
		}
		num += day;
		return num;
	}
};
int main() {
	int a, b, c;
	cin >> a >> b >> c;
	Date D(a, b, c);
	int day = D.getDay();
	cout << day;
	return 0;
}